package com.qf.ems.controller;

import com.qf.ems.entity.User;
import com.qf.ems.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
//@RequestMapping("/user")
/*2021/10/22*/public class UserController {

    @Autowired
    UserService userService;
    @RequestMapping("/login")
    public String login(User user, HttpSession session){
        User user1 = userService.selectOneInfo(user.getUsername(),user.getPassword());
        if(user!=null){
            session.setAttribute("user", user1);
            return "forward:/page";
        }else{
            return "redirect:/login.jsp";
        }
    }
}
